<!DOCTYPE html>
<html lang="en">
  <head>
    <title>SortedBag Struct Reference</title>
    <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
    <meta charset="utf-8">
    <script src="../js/jquery.min.js" defer></script>
    <script src="../js/jazzy.js" defer></script>
    
  </head>
  <body>

    <a name="//apple_ref/swift/Struct/SortedBag" class="dashAnchor"></a>

    <a title="SortedBag Struct Reference"></a>

    <header class="header">
      <p class="header-col header-col--primary">
        <a class="header-link" href="../index.html">
          BTree Docs
        </a>
         (100% documented)
      </p>
    
        <p class="header-col header-col--secondary">
          <a class="header-link" href="https://github.com/lorentey/BTree">
            <img class="header-icon" src="../img/gh.png"/>
            View on GitHub
          </a>
        </p>
    
        <p class="header-col header-col--secondary">
          <a class="header-link" href="dash-feed://https%3A%2F%2Florentey%2Egithub%2Eio%2FBTree%2Freference%2Fdocsets%2FBTree%2Exml">
            <img class="header-icon" src="../img/dash.png"/>
            Install in Dash
          </a>
        </p>
    </header>

    <p class="breadcrumbs">
      <a class="breadcrumb" href="../index.html">BTree Reference</a>
      <img class="carat" src="../img/carat.png" />
      SortedBag Struct Reference
    </p>

    <div class="content-wrapper">
      <nav class="navigation">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/BTreeCursor.html">BTreeCursor</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Enums.html">Enums</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Enums/BTreeKeySelector.html">BTreeKeySelector</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Enums/BTreeMatchingStrategy.html">BTreeMatchingStrategy</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Structs.html">Structs</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/BTree.html">BTree</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/BTreeIndex.html">BTreeIndex</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/BTreeIterator.html">BTreeIterator</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/BTreeKeyIterator.html">BTreeKeyIterator</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/BTreeValueIterator.html">BTreeValueIterator</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/List.html">List</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/Map.html">Map</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/SortedBag.html">SortedBag</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/SortedSet.html">SortedSet</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">

        <section class="section">
          <div class="section-content">
            <h1>SortedBag</h1>
              <div class="declaration">
                <div class="language">
                  <pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="p">:</span> <span class="kt">Comparable</span><span class="o">&gt;</span><span class="p">:</span> <span class="kt">SetAlgebra</span></code></pre>

                </div>
              </div>
            <p>A sorted collection of comparable elements; also known as a multiset.
<code>SortedBag</code> is like a <code><a href="../Structs/SortedSet.html">SortedSet</a></code> except it can contain multiple members that are equal to each other.
Lookup, insertion and removal of any element has logarithmic complexity.</p>

<p><code>SortedBag</code> stores duplicate elements in their entirety; it doesn&rsquo;t just count multiplicities.
This is an important feature when equal elements can be distinguished by identity comparison or some other means.
(If you&rsquo;re OK with just counting duplicates, use a <code><a href="../Structs/Map.html">Map</a></code> or a <code>Dictionary</code> with the multiplicity as the value.)</p>

<p><code>SortedBag</code> is a struct with copy-on-write value semantics, like Swift&rsquo;s standard collection types.
It uses an in-memory b-tree for element storage, whose individual nodes may be shared with other sorted sets or bags.
Mutating a bag whose storage is (partially or completely) shared requires copying of only O(log(<code>count</code>)) elements.
(Thus, mutation of shared <code>SortedBag</code>s may be cheaper than ordinary <code>Set</code>s, which need to copy all elements.)</p>

<p>Set operations on sorted bags (such as taking the union, intersection or difference) can take as little as
O(log(n)) time if the elements in the input bags aren&rsquo;t too interleaved.</p>

<div class="aside aside-see-also">
    <p class="aside-title">See also</p>
    <code><a href="../Structs/SortedSet.html">SortedSet</a></code>

</div>

          </div>
        </section>

        <section class="section">
          <div class="section-content">
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Initializers"></a>
                <a name="//apple_ref/swift/Section/Initializers" class="dashAnchor"></a>
                <a href="#/Initializers">
                  <h3 class="section-name">Initializers</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBagcFT_GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/init()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBagcFT_GS0_x_">init()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Create an empty bag.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">()</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L41-L43">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBagcFGVS_9SortedSetx_GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBagcFGVS_9SortedSetx_GS0_x_">init(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Create a bag that holds the same members as the specified sorted set.</p>

<p>Complexity: O(1); the new bag simply refers to the same storage as the set.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">set</span><span class="p">:</span> <span class="kt"><a href="../Structs/SortedSet.html">SortedSet</a></span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L48-L50">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBagcuRd__s8SequencexzWd__8Iterator7Element_rFqd__GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBagcuRd__s8SequencexzWd__8Iterator7Element_rFqd__GS0_x_">init(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Create a bag from a finite sequence of items. The sequence need not be sorted.
If the sequence contains duplicate items, all of them are kept, in the same order.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(<em>n</em> * log(<em>n</em>)), where <em>n</em> is the number of items in the sequence.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">init</span><span class="o">&lt;</span><span class="kt">S</span><span class="p">:</span> <span class="kt">Sequence</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span> <span class="nv">elements</span><span class="p">:</span> <span class="kt">S</span><span class="p">)</span> <span class="k">where</span> <span class="kt">S</span><span class="o">.</span><span class="kt">Iterator</span><span class="o">.</span><span class="kt">Element</span> <span class="o">==</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L56-L58">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBagcuRd__s8SequencexzWd__8Iterator7Element_rFT14sortedElementsqd___GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/init(sortedElements:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBagcuRd__s8SequencexzWd__8Iterator7Element_rFT14sortedElementsqd___GS0_x_">init(sortedElements:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Create a bag from a sorted finite sequence of items.
If the sequence contains duplicate items, all of them are kept.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(<em>n</em>), where <em>n</em> is the number of items in the sequence.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">init</span><span class="o">&lt;</span><span class="kt">S</span><span class="p">:</span> <span class="kt">Sequence</span><span class="o">&gt;</span><span class="p">(</span><span class="n">sortedElements</span> <span class="nv">elements</span><span class="p">:</span> <span class="kt">S</span><span class="p">)</span> <span class="k">where</span> <span class="kt">S</span><span class="o">.</span><span class="kt">Iterator</span><span class="o">.</span><span class="kt">Element</span> <span class="o">==</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L64-L66">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBagcFt12arrayLiteralGSax__GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/init(arrayLiteral:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBagcFt12arrayLiteralGSax__GS0_x_">init(arrayLiteral:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Create a bag with the specified list of items.
If the array literal contains duplicate items, all of them are kept.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">arrayLiteral</span> <span class="nv">elements</span><span class="p">:</span> <span class="kt">Element</span><span class="o">...</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L70-L72">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/CollectionType"></a>
                <a name="//apple_ref/swift/Section/CollectionType" class="dashAnchor"></a>
                <a href="#/CollectionType">
                  <h3 class="section-name">CollectionType</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:iV5BTree9SortedBag9subscriptFGVS_10BTreeIndexxT__x"></a>
                    <a name="//apple_ref/swift/Method/subscript(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:iV5BTree9SortedBag9subscriptFGVS_10BTreeIndexxT__x">subscript(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the element at the given index.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> originated from an unmutated copy of this set.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(1)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L110">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:iV5BTree9SortedBag9subscriptFGVs5RangeGVS_10BTreeIndexxT___GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/subscript(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:iV5BTree9SortedBag9subscriptFGVs5RangeGVS_10BTreeIndexxT___GS0_x_">subscript(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return the subbag consisting of elements in the given range of indexes.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    The indices in <code>range</code> originated from an unmutated copy of this bag.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="nv">range</span><span class="p">:</span> <span class="kt">Range</span><span class="o">&lt;</span><span class="kt">Index</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L118">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree9SortedBag10startIndexGVS_10BTreeIndexxT__"></a>
                    <a name="//apple_ref/swift/Property/startIndex" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree9SortedBag10startIndexGVS_10BTreeIndexxT__">startIndex</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>The index of the first element when non-empty. Otherwise the same as <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__">endIndex</a></code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">startIndex</span><span class="p">:</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L85-L87">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__"></a>
                    <a name="//apple_ref/swift/Property/endIndex" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__">endIndex</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>The <q>past-the-end</q> element index; the successor of the last valid subscript argument.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(1)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">endIndex</span><span class="p">:</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L92-L94">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree9SortedBag5countSi"></a>
                    <a name="//apple_ref/swift/Property/count" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree9SortedBag5countSi">count</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>The number of elements in this bag.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L97-L99">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree9SortedBag7isEmptySb"></a>
                    <a name="//apple_ref/swift/Property/isEmpty" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree9SortedBag7isEmptySb">isEmpty</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>True iff this collection has no elements.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">isEmpty</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L102-L104">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag12makeIteratorFT_GVS_16BTreeKeyIteratorx_"></a>
                    <a name="//apple_ref/swift/Method/makeIterator()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag12makeIteratorFT_GVS_16BTreeKeyIteratorx_">makeIterator()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return an iterator over all elements in this map, in ascending key order.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">makeIterator</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Iterator</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L123-L125">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag5indexFT5afterGVS_10BTreeIndexxT___GS1_xT__"></a>
                    <a name="//apple_ref/swift/Method/index(after:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag5indexFT5afterGVS_10BTreeIndexxT___GS1_xT__">index(after:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the successor of the given index.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> is a valid index of this bag and it is not equal to <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__">endIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    Amortized O(1).

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">after</span> <span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L131-L133">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag9formIndexFT5afterRGVS_10BTreeIndexxT___T_"></a>
                    <a name="//apple_ref/swift/Method/formIndex(after:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag9formIndexFT5afterRGVS_10BTreeIndexxT___T_">formIndex(after:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Replaces the given index with its successor.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> is a valid index of this bag and it is not equal to <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__">endIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    Amortized O(1).

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">formIndex</span><span class="p">(</span><span class="n">after</span> <span class="nv">index</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Index</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L139-L141">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag5indexFT6beforeGVS_10BTreeIndexxT___GS1_xT__"></a>
                    <a name="//apple_ref/swift/Method/index(before:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag5indexFT6beforeGVS_10BTreeIndexxT___GS1_xT__">index(before:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the predecessor of the given index.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> is a valid index of this bag and it is not equal to <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag10startIndexGVS_10BTreeIndexxT__">startIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    Amortized O(1).

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">before</span> <span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L147-L149">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag9formIndexFT6beforeRGVS_10BTreeIndexxT___T_"></a>
                    <a name="//apple_ref/swift/Method/formIndex(before:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag9formIndexFT6beforeRGVS_10BTreeIndexxT___T_">formIndex(before:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Replaces the given index with its predecessor.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> is a valid index of this bag and it is not equal to <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag10startIndexGVS_10BTreeIndexxT__">startIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    Amortized O(1).

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">formIndex</span><span class="p">(</span><span class="n">before</span> <span class="nv">index</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Index</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L155-L157">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag5indexFTGVS_10BTreeIndexxT__8offsetBySi_GS1_xT__"></a>
                    <a name="//apple_ref/swift/Method/index(_:offsetBy:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag5indexFTGVS_10BTreeIndexxT__8offsetBySi_GS1_xT__">index(_:offsetBy:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns an index that is at the specified distance from the given index.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> must be a valid index of this set.
         If <code>n</code> is positive, it must not exceed the distance from <code>index</code> to <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__">endIndex</a></code>.
         If <code>n</code> is negative, it must not be less than the distance from <code>index</code> to <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag10startIndexGVS_10BTreeIndexxT__">startIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<em>count</em>)) where <em>count</em> is the number of elements in the set.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">_</span> <span class="nv">i</span><span class="p">:</span> <span class="kt">Index</span><span class="p">,</span> <span class="n">offsetBy</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L165-L167">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag9formIndexFTRGVS_10BTreeIndexxT__8offsetBySi_T_"></a>
                    <a name="//apple_ref/swift/Method/formIndex(_:offsetBy:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag9formIndexFTRGVS_10BTreeIndexxT__8offsetBySi_T_">formIndex(_:offsetBy:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Offsets the given index by the specified distance.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> must be a valid index of this set.
         If <code>n</code> is positive, it must not exceed the distance from <code>index</code> to <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__">endIndex</a></code>.
         If <code>n</code> is negative, it must not be less than the distance from <code>index</code> to <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag10startIndexGVS_10BTreeIndexxT__">startIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<em>count</em>)) where <em>count</em> is the number of elements in the bag.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">formIndex</span><span class="p">(</span><span class="n">_</span> <span class="nv">i</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Index</span><span class="p">,</span> <span class="n">offsetBy</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L175-L177">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag5indexFTGVS_10BTreeIndexxT__8offsetBySi9limitedByGS1_xT___GSqGS1_xT___"></a>
                    <a name="//apple_ref/swift/Method/index(_:offsetBy:limitedBy:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag5indexFTGVS_10BTreeIndexxT__8offsetBySi9limitedByGS1_xT___GSqGS1_xT___">index(_:offsetBy:limitedBy:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns an index that is at the specified distance from the given index, unless that distance is beyond a given limiting index.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> and <code>limit</code> must be valid indices in this bag. The operation must not advance the index beyond <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__">endIndex</a></code> or before <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag10startIndexGVS_10BTreeIndexxT__">startIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<em>count</em>)) where <em>count</em> is the number of elements in the bag.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">_</span> <span class="nv">i</span><span class="p">:</span> <span class="kt">Index</span><span class="p">,</span> <span class="n">offsetBy</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="n">limitedBy</span> <span class="nv">limit</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Index</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L183-L185">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag9formIndexFTRGVS_10BTreeIndexxT__8offsetBySi9limitedByGS1_xT___Sb"></a>
                    <a name="//apple_ref/swift/Method/formIndex(_:offsetBy:limitedBy:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag9formIndexFTRGVS_10BTreeIndexxT__8offsetBySi9limitedByGS1_xT___Sb">formIndex(_:offsetBy:limitedBy:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Offsets the given index by the specified distance, or so that it equals the given limiting index.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> and <code>limit</code> must be valid indices in this bag. The operation must not advance the index beyond <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__">endIndex</a></code> or before <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag10startIndexGVS_10BTreeIndexxT__">startIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<em>count</em>)) where <em>count</em> is the number of elements in the bag.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">formIndex</span><span class="p">(</span><span class="n">_</span> <span class="nv">i</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Index</span><span class="p">,</span> <span class="n">offsetBy</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="n">limitedBy</span> <span class="nv">limit</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L192-L194">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag8distanceFT4fromGVS_10BTreeIndexxT__2toGS1_xT___Si"></a>
                    <a name="//apple_ref/swift/Method/distance(from:to:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag8distanceFT4fromGVS_10BTreeIndexxT__2toGS1_xT___Si">distance(from:to:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the distance between two indices.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>start</code> and <code>end</code> must be valid indices in this bag.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(1)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">distance</span><span class="p">(</span><span class="n">from</span> <span class="nv">start</span><span class="p">:</span> <span class="kt">Index</span><span class="p">,</span> <span class="n">to</span> <span class="nv">end</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L200-L202">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Offset-based%20access"></a>
                <a name="//apple_ref/swift/Section/Offset-based access" class="dashAnchor"></a>
                <a href="#/Offset-based%20access">
                  <h3 class="section-name">Offset-based access</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:iV5BTree9SortedBag9subscriptFGVs5RangeSi_GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/subscript(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:iV5BTree9SortedBag9subscriptFGVs5RangeSi_GS0_x_">subscript(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the subbag containing elements in the specified range of offsets from the start of the bag.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="nv">offsetRange</span><span class="p">:</span> <span class="kt">Range</span><span class="o">&lt;</span><span class="kt">Int</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L240">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:iV5BTree9SortedBag9subscriptFSix"></a>
                    <a name="//apple_ref/swift/Method/subscript(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:iV5BTree9SortedBag9subscriptFSix">subscript(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the element at <code>offset</code> from the start of the bag.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="nv">offset</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L233">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6offsetFT2ofx_GSqSi_"></a>
                    <a name="//apple_ref/swift/Method/offset(of:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6offsetFT2ofx_GSqSi_">offset(of:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>If <code>member</code> is in this bag, return the offset of its first instance. Otherwise, return <code>nil</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">offset</span><span class="p">(</span><span class="n">of</span> <span class="nv">member</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Int</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L211-L213">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag5indexFT8ofOffsetSi_GVS_10BTreeIndexxT__"></a>
                    <a name="//apple_ref/swift/Method/index(ofOffset:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag5indexFT8ofOffsetSi_GVS_10BTreeIndexxT__">index(ofOffset:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the offset of the element at <code>index</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">ofOffset</span> <span class="nv">offset</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L218-L220">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6offsetFT2ofGVS_10BTreeIndexxT___Si"></a>
                    <a name="//apple_ref/swift/Method/offset(of:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6offsetFT2ofGVS_10BTreeIndexxT___Si">offset(of:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the index of the element at <code>offset</code>.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>offset &gt;= 0 &amp;&amp; offset &lt; count</code>

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">offset</span><span class="p">(</span><span class="n">of</span> <span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L226-L228">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Algorithms"></a>
                <a name="//apple_ref/swift/Section/Algorithms" class="dashAnchor"></a>
                <a href="#/Algorithms">
                  <h3 class="section-name">Algorithms</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag7forEachFzFzxT_T_"></a>
                    <a name="//apple_ref/swift/Method/forEach(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag7forEachFzFzxT_T_">forEach(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Call <code>body</code> on each element in <code>self</code> in ascending order.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">forEach</span><span class="p">(</span><span class="n">_</span> <span class="nv">body</span><span class="p">:</span> <span class="p">(</span><span class="kt">Element</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span> <span class="k">rethrows</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L249-L251">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag3mapurFzFzxqd__GSaqd___"></a>
                    <a name="//apple_ref/swift/Method/map(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag3mapurFzFzxqd__GSaqd___">map(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return an <code>Array</code> containing the results of mapping transform over <code>self</code>.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">map</span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span> <span class="nv">transform</span><span class="p">:</span> <span class="p">(</span><span class="kt">Element</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">T</span><span class="p">)</span> <span class="k">rethrows</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="kt">T</span><span class="p">]</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L254-L256">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag7flatMapuRd__s8SequencerFzFzxqd__GSaWd__8Iterator7Element__"></a>
                    <a name="//apple_ref/swift/Method/flatMap(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag7flatMapuRd__s8SequencerFzFzxqd__GSaWd__8Iterator7Element__">flatMap(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return an <code>Array</code> containing the concatenated results of mapping <code>transform</code> over <code>self</code>.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">flatMap</span><span class="o">&lt;</span><span class="kt">S</span> <span class="p">:</span> <span class="kt">Sequence</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span> <span class="nv">transform</span><span class="p">:</span> <span class="p">(</span><span class="kt">Element</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">S</span><span class="p">)</span> <span class="k">rethrows</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="kt">S</span><span class="o">.</span><span class="kt">Iterator</span><span class="o">.</span><span class="kt">Element</span><span class="p">]</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L259-L261">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag7flatMapurFzFzxGSqqd___GSaqd___"></a>
                    <a name="//apple_ref/swift/Method/flatMap(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag7flatMapurFzFzxGSqqd___GSaqd___">flatMap(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return an <code>Array</code> containing the non-<code>nil</code> results of mapping <code>transform</code> over <code>self</code>.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">flatMap</span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span> <span class="nv">transform</span><span class="p">:</span> <span class="p">(</span><span class="kt">Element</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">T</span><span class="p">?)</span> <span class="k">rethrows</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="kt">T</span><span class="p">]</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L264-L266">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6filterFzFzxSbGSax_"></a>
                    <a name="//apple_ref/swift/Method/filter(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6filterFzFzxSbGSax_">filter(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return an <code>Array</code> containing the elements of <code>self</code>, in ascending order, that satisfy the predicate <code>includeElement</code>.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">filter</span><span class="p">(</span><span class="n">_</span> <span class="nv">includeElement</span><span class="p">:</span> <span class="p">(</span><span class="kt">Element</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">Bool</span><span class="p">)</span> <span class="k">rethrows</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="kt">Element</span><span class="p">]</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L269-L277">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6reduceurFzTqd__FzTqd__x_qd___qd__"></a>
                    <a name="//apple_ref/swift/Method/reduce(_:_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6reduceurFzTqd__FzTqd__x_qd___qd__">reduce(_:_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return the result of repeatedly calling <code>combine</code> with an accumulated value initialized to <code>initial</code>
and each element of <code>self</code>, in turn.
I.e., return <code>combine(combine(...combine(combine(initial, self[0]), self[1]),...self[count-2]), self[count-1])</code>.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">reduce</span><span class="o">&lt;</span><span class="kt">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span> <span class="nv">initialResult</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="n">_</span> <span class="nv">nextPartialResult</span><span class="p">:</span> <span class="p">(</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Element</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">T</span><span class="p">)</span> <span class="k">rethrows</span> <span class="o">-&gt;</span> <span class="kt">T</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L282-L284">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Extractions"></a>
                <a name="//apple_ref/swift/Section/Extractions" class="dashAnchor"></a>
                <a href="#/Extractions">
                  <h3 class="section-name">Extractions</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree9SortedBag5firstGSqx_"></a>
                    <a name="//apple_ref/swift/Property/first" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree9SortedBag5firstGSqx_">first</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return (the first instance of) the smallest element in the bag, or <code>nil</code> if the bag is empty.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">first</span><span class="p">:</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L293">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree9SortedBag4lastGSqx_"></a>
                    <a name="//apple_ref/swift/Property/last" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree9SortedBag4lastGSqx_">last</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return (the last instance of) the largest element in the bag, or <code>nil</code> if the bag is empty.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">last</span><span class="p">:</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L298">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag3minFT_GSqx_"></a>
                    <a name="//apple_ref/swift/Method/min()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag3minFT_GSqx_">min()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return the smallest element in the bag, or <code>nil</code> if the bag is empty. This is the same as <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5firstGSqx_">first</a></code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">min</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L303">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag3maxFT_GSqx_"></a>
                    <a name="//apple_ref/swift/Method/max()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag3maxFT_GSqx_">max()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return the largest element in the set, or <code>nil</code> if the set is empty. This is the same as <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag4lastGSqx_">last</a></code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">max</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L308">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag9dropFirstFT_GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/dropFirst()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag9dropFirstFT_GS0_x_">dropFirst()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>If this bag is empty, the result is an empty bag.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">dropFirst</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L314-L316">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag9dropFirstFSiGS0_x_"></a>
                    <a name="//apple_ref/swift/Method/dropFirst(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag9dropFirstFSiGS0_x_">dropFirst(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a copy of this bag with the <code>n</code> smallest elements removed.
If <code>n</code> exceeds the number of elements in the bag, the result is an empty bag.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">dropFirst</span><span class="p">(</span><span class="n">_</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L322-L324">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag8dropLastFT_GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/dropLast()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag8dropLastFT_GS0_x_">dropLast()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a copy of this bag with the largest element removed.
If this bag is empty, the result is an empty bag.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">dropLast</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L330-L332">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag8dropLastFSiGS0_x_"></a>
                    <a name="//apple_ref/swift/Method/dropLast(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag8dropLastFSiGS0_x_">dropLast(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a copy of this bag with the <code>n</code> largest elements removed.
If <code>n</code> exceeds the number of elements in the bag, the result is an empty bag.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">dropLast</span><span class="p">(</span><span class="n">_</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L338-L340">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6prefixFSiGS0_x_"></a>
                    <a name="//apple_ref/swift/Method/prefix(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6prefixFSiGS0_x_">prefix(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subbag, up to <code>maxLength</code> in size, containing the smallest elements in this bag.</p>

<p>If <code>maxLength</code> exceeds the number of elements, the result contains all the elements of <code>self</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prefix</span><span class="p">(</span><span class="n">_</span>  <span class="nv">maxLength</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L347-L349">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6prefixFT7throughGVS_10BTreeIndexxT___GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/prefix(through:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6prefixFT7throughGVS_10BTreeIndexxT___GS0_x_">prefix(through:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subbag containing all members of this bag at or before the specified index.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prefix</span><span class="p">(</span><span class="n">through</span> <span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L354-L356">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6prefixFT7throughx_GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/prefix(through:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6prefixFT7throughx_GS0_x_">prefix(through:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subset containing all members of this bag less than or equal to the specified element
(which may or may not be a member of this bag).</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prefix</span><span class="p">(</span><span class="n">through</span> <span class="nv">element</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L362-L364">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6prefixFT4upToGVS_10BTreeIndexxT___GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/prefix(upTo:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6prefixFT4upToGVS_10BTreeIndexxT___GS0_x_">prefix(upTo:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subbag containing all members of this bag before the specified index.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prefix</span><span class="p">(</span><span class="n">upTo</span> <span class="nv">end</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L369-L371">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6prefixFT4upTox_GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/prefix(upTo:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6prefixFT4upTox_GS0_x_">prefix(upTo:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subbag containing all members of this bag less than the specified element
(which may or may not be a member of this bag).</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prefix</span><span class="p">(</span><span class="n">upTo</span> <span class="nv">end</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L377-L379">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6suffixFSiGS0_x_"></a>
                    <a name="//apple_ref/swift/Method/suffix(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6suffixFSiGS0_x_">suffix(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subbag, up to <code>maxLength</code> in size, containing the largest elements in this bag.</p>

<p>If <code>maxLength</code> exceeds the number of members, the result contains all the elements of <code>self</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">suffix</span><span class="p">(</span><span class="n">_</span> <span class="nv">maxLength</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L386-L388">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6suffixFT4fromGVS_10BTreeIndexxT___GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/suffix(from:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6suffixFT4fromGVS_10BTreeIndexxT___GS0_x_">suffix(from:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subbag containing all members of this bag at or after the specified index.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">suffix</span><span class="p">(</span><span class="n">from</span> <span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L393-L395">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6suffixFT4fromx_GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/suffix(from:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6suffixFT4fromx_GS0_x_">suffix(from:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subset containing all members of this bag greater than or equal to the specified element
(which may or may not be a member of this bag).</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">suffix</span><span class="p">(</span><span class="n">from</span> <span class="nv">element</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L401-L403">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Conversion%20to%20string"></a>
                <a name="//apple_ref/swift/Section/Conversion to string" class="dashAnchor"></a>
                <a href="#/Conversion%20to%20string">
                  <h3 class="section-name">Conversion to string</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree9SortedBag11descriptionSS"></a>
                    <a name="//apple_ref/swift/Property/description" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree9SortedBag11descriptionSS">description</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>A textual representation of this bag.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">description</span><span class="p">:</span> <span class="kt">String</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L410-L413">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree9SortedBag16debugDescriptionSS"></a>
                    <a name="//apple_ref/swift/Property/debugDescription" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree9SortedBag16debugDescriptionSS">debugDescription</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>A textual representation of this bag, suitable for debugging.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">debugDescription</span><span class="p">:</span> <span class="kt">String</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L416-L418">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Queries"></a>
                <a name="//apple_ref/swift/Section/Queries" class="dashAnchor"></a>
                <a href="#/Queries">
                  <h3 class="section-name">Queries</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag8containsFxSb"></a>
                    <a name="//apple_ref/swift/Method/contains(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag8containsFxSb">contains(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return true if the bag contains <code>element</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">contains</span><span class="p">(</span><span class="n">_</span> <span class="nv">element</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L427-L429">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag5countFT2ofx_Si"></a>
                    <a name="//apple_ref/swift/Method/count(of:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag5countFT2ofx_Si">count(of:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the multiplicity of <code>member</code> in this bag, i.e. the number of instances of <code>member</code> contained in the bag.
Returns 0 if <code>member</code> is not an element.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">count</span><span class="p">(</span><span class="n">of</span> <span class="nv">member</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L435-L440">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag5indexFT2ofx_GSqGVS_10BTreeIndexxT___"></a>
                    <a name="//apple_ref/swift/Method/index(of:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag5indexFT2ofx_GSqGVS_10BTreeIndexxT___">index(of:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the index of the first instance of a given member, or <code>nil</code> if the member is not present in the bag.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">of</span> <span class="nv">member</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/BTreeIndex.html">BTreeIndex</a></span><span class="o">&lt;</span><span class="kt">Element</span><span class="p">,</span> <span class="kt">Void</span><span class="o">&gt;</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L445-L447">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag19indexOfFirstElementFT5afterx_GSqGVS_10BTreeIndexxT___"></a>
                    <a name="//apple_ref/swift/Method/indexOfFirstElement(after:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag19indexOfFirstElementFT5afterx_GSqGVS_10BTreeIndexxT___">indexOfFirstElement(after:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the index of the lowest member of this bag that is strictly greater than <code>element</code>, or <code>nil</code> if there is no such element.</p>

<p>This function never returns <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__">endIndex</a></code>. (If it returns non-nil, the returned index can be used to subscript the bag.)</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">indexOfFirstElement</span><span class="p">(</span><span class="n">after</span> <span class="nv">element</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/BTreeIndex.html">BTreeIndex</a></span><span class="o">&lt;</span><span class="kt">Element</span><span class="p">,</span> <span class="kt">Void</span><span class="o">&gt;</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L454-L458">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag19indexOfFirstElementFT9notBeforex_GSqGVS_10BTreeIndexxT___"></a>
                    <a name="//apple_ref/swift/Method/indexOfFirstElement(notBefore:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag19indexOfFirstElementFT9notBeforex_GSqGVS_10BTreeIndexxT___">indexOfFirstElement(notBefore:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the index of the lowest member of this bag that is greater than or equal to <code>element</code>, or <code>nil</code> if there is no such element.</p>

<p>This function never returns <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__">endIndex</a></code>. (If it returns non-nil, the returned index can be used to subscript the bag.)</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">indexOfFirstElement</span><span class="p">(</span><span class="n">notBefore</span> <span class="nv">element</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/BTreeIndex.html">BTreeIndex</a></span><span class="o">&lt;</span><span class="kt">Element</span><span class="p">,</span> <span class="kt">Void</span><span class="o">&gt;</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L465-L469">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag18indexOfLastElementFT6beforex_GSqGVS_10BTreeIndexxT___"></a>
                    <a name="//apple_ref/swift/Method/indexOfLastElement(before:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag18indexOfLastElementFT6beforex_GSqGVS_10BTreeIndexxT___">indexOfLastElement(before:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the index of the highest member of this bag that is strictly less than <code>element</code>, or <code>nil</code> if there is no such element.</p>

<p>This function never returns <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__">endIndex</a></code>. (If it returns non-nil, the returned index can be used to subscript the bag.)</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">indexOfLastElement</span><span class="p">(</span><span class="n">before</span> <span class="nv">element</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/BTreeIndex.html">BTreeIndex</a></span><span class="o">&lt;</span><span class="kt">Element</span><span class="p">,</span> <span class="kt">Void</span><span class="o">&gt;</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L476-L481">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag18indexOfLastElementFT8notAfterx_GSqGVS_10BTreeIndexxT___"></a>
                    <a name="//apple_ref/swift/Method/indexOfLastElement(notAfter:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag18indexOfLastElementFT8notAfterx_GSqGVS_10BTreeIndexxT___">indexOfLastElement(notAfter:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the index of the highest member of this bag that is less than or equal to <code>element</code>, or <code>nil</code> if there is no such element.</p>

<p>This function never returns <code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag8endIndexGVS_10BTreeIndexxT__">endIndex</a></code>. (If it returns non-nil, the returned index can be used to subscript the bag.)</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">indexOfLastElement</span><span class="p">(</span><span class="n">notAfter</span> <span class="nv">element</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/BTreeIndex.html">BTreeIndex</a></span><span class="o">&lt;</span><span class="kt">Element</span><span class="p">,</span> <span class="kt">Void</span><span class="o">&gt;</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L488-L493">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Set%20comparions"></a>
                <a name="//apple_ref/swift/Section/Set comparions" class="dashAnchor"></a>
                <a href="#/Set%20comparions">
                  <h3 class="section-name">Set comparions</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag13elementsEqualFGS0_x_Sb"></a>
                    <a name="//apple_ref/swift/Method/elementsEqual(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag13elementsEqualFGS0_x_Sb">elementsEqual(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return <code>true</code> iff <code>self</code> and <code>other</code> contain the same number of instances of all the same elements.</p>

<p>This method skips over shared subtrees when possible; this can drastically improve performance when the
two bags are divergent mutations originating from the same value.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">elementsEqual</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L505-L507">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:ZFV5BTree9SortedBagoi2eeFTGS0_x_GS0_x__Sb"></a>
                    <a name="//apple_ref/swift/Method/==(_:_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:ZFV5BTree9SortedBagoi2eeFTGS0_x_GS0_x__Sb">==(_:_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns <code>true</code> iff <code>a</code> contains the exact same elements as <code>b</code>, including multiplicities.</p>

<p>This function skips over shared subtrees when possible; this can drastically improve performance when the
two bags are divergent mutations originating from the same value.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="o">==</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L515-L517">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag10isDisjointFT4withGS0_x__Sb"></a>
                    <a name="//apple_ref/swift/Method/isDisjoint(with:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag10isDisjointFT4withGS0_x__Sb">isDisjoint(with:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns <code>true</code> iff no members in this bag are also included in <code>other</code>.</p>

<p>The elements of the two input bags may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input bags may be skipped instead
of elementwise processing, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">isDisjoint</span><span class="p">(</span><span class="n">with</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L528-L530">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag8isSubsetFT2ofGS0_x__Sb"></a>
                    <a name="//apple_ref/swift/Method/isSubset(of:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag8isSubsetFT2ofGS0_x__Sb">isSubset(of:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns <code>true</code> iff all members in this bag are also included in <code>other</code>.</p>

<p>The elements of the two input bags may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input bags may be skipped instead
of elementwise processing, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">isSubset</span><span class="p">(</span><span class="n">of</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L541-L543">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag14isStrictSubsetFT2ofGS0_x__Sb"></a>
                    <a name="//apple_ref/swift/Method/isStrictSubset(of:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag14isStrictSubsetFT2ofGS0_x__Sb">isStrictSubset(of:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns <code>true</code> iff all members in this bag are also included in <code>other</code>, but the two bags aren&rsquo;t equal.</p>

<p>The elements of the two input bags may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input bags may be skipped instead
of elementwise processing, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">isStrictSubset</span><span class="p">(</span><span class="n">of</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L554-L556">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag10isSupersetFT2ofGS0_x__Sb"></a>
                    <a name="//apple_ref/swift/Method/isSuperset(of:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag10isSupersetFT2ofGS0_x__Sb">isSuperset(of:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns <code>true</code> iff all members in <code>other</code> are also included in this bag.</p>

<p>The elements of the two input bags may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input bags may be skipped instead
of elementwise processing, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">isSuperset</span><span class="p">(</span><span class="n">of</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L567-L569">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag16isStrictSupersetFT2ofGS0_x__Sb"></a>
                    <a name="//apple_ref/swift/Method/isStrictSuperset(of:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag16isStrictSupersetFT2ofGS0_x__Sb">isStrictSuperset(of:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns <code>true</code> iff all members in <code>other</code> are also included in this bag, but the two bags aren&rsquo;t equal.</p>

<p>The elements of the two input bags may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input bags may be skipped instead
of elementwise processing, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">isStrictSuperset</span><span class="p">(</span><span class="n">of</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L580-L582">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Insertion"></a>
                <a name="//apple_ref/swift/Section/Insertion" class="dashAnchor"></a>
                <a href="#/Insertion">
                  <h3 class="section-name">Insertion</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6insertFxT8insertedSb17memberAfterInsertx_"></a>
                    <a name="//apple_ref/swift/Method/insert(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6insertFxT8insertedSb17memberAfterInsertx_">insert(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Unconditionally insert a new member into the bag, adding another instance if the member was already present.</p>

<p>The new member is inserted after its existing instances, if any. (This is important when equal members can
be distinguished by identity comparison or some other means.)</p>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    <p><code>SetAlgebra</code> requires <code>insert</code> to do nothing and return <code>(false, member)</code> if the set already contains 
a matching element. <code>SortedBag</code> ignores this requirement and always inserts a new copy of the specified element.</p>

</div>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    <p>Parameter newMember: An element to insert into the set.</p>

</div>

<div class="aside aside-returns">
    <p class="aside-title">Returns</p>
    <p><code>(true, newMember)</code> to satisfy the syntactic requirements of the <code>SetAlgebra</code> protocol.</p>

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <p>O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))</p>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">insert</span><span class="p">(</span><span class="n">_</span> <span class="nv">newMember</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="nv">inserted</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">,</span> <span class="nv">memberAfterInsert</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>newMember</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>An element to insert into the set.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p><code>(true, newMember)</code> to satisfy the syntactic requirements of the <code>SetAlgebra</code> protocol.</p>

                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L602-L605">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6updateFT4withx_GSqx_"></a>
                    <a name="//apple_ref/swift/Method/update(with:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6updateFT4withx_GSqx_">update(with:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Unconditionally insert a new member into the bag, adding another instance if the member was already present.</p>

<p>The new member is inserted before its existing instances, if any. (This is important when equal members can
be distinguished by identity comparison or some other means.)</p>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    <p><code>SetAlgebra</code> requires <code>update</code> to replace and return an existing member if the set already contains
a matching element. <code>SortedBag</code> ignores this requirement and always inserts a new copy of the specified element.</p>

</div>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    <p>Parameter newMember: An element to insert into the set.</p>

</div>

<div class="aside aside-returns">
    <p class="aside-title">Returns</p>
    <p>Always returns <code>nil</code>, to satisfy the syntactic requirements of the <code>SetAlgebra</code> protocol.</p>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">update</span><span class="p">(</span><span class="n">with</span> <span class="nv">newMember</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>newMember</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>An element to insert into the set.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>Always returns <code>nil</code>, to satisfy the syntactic requirements of the <code>SetAlgebra</code> protocol.</p>

                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L619-L622">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Removal"></a>
                <a name="//apple_ref/swift/Section/Removal" class="dashAnchor"></a>
                <a href="#/Removal">
                  <h3 class="section-name">Removal</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6removeFxGSqx_"></a>
                    <a name="//apple_ref/swift/Method/remove(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6removeFxGSqx_">remove(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove and return the first instance of <code>member</code> from the bag, or return <code>nil</code> if the bag contains no instances of <code>member</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">remove</span><span class="p">(</span><span class="n">_</span> <span class="nv">member</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L632-L634">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag9removeAllFxT_"></a>
                    <a name="//apple_ref/swift/Method/removeAll(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag9removeAllFxT_">removeAll(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove all instances of <code>member</code> from the bag.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">removeAll</span><span class="p">(</span><span class="n">_</span> <span class="nv">member</span><span class="p">:</span> <span class="kt">Element</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L639-L644">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6removeFT2atGVS_10BTreeIndexxT___x"></a>
                    <a name="//apple_ref/swift/Method/remove(at:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6removeFT2atGVS_10BTreeIndexxT___x">remove(at:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove the member referenced by the given index.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">remove</span><span class="p">(</span><span class="n">at</span> <span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L650-L652">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6removeFT8atOffsetSi_x"></a>
                    <a name="//apple_ref/swift/Method/remove(atOffset:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6removeFT8atOffsetSi_x">remove(atOffset:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove the member at the given offset.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">remove</span><span class="p">(</span><span class="n">atOffset</span> <span class="nv">offset</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L658-L660">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag8popFirstFT_GSqx_"></a>
                    <a name="//apple_ref/swift/Method/popFirst()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag8popFirstFT_GSqx_">popFirst()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove and return the smallest member in this bag, or return <code>nil</code> if the bag is empty.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">popFirst</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L682-L684">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag7popLastFT_GSqx_"></a>
                    <a name="//apple_ref/swift/Method/popLast()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag7popLastFT_GSqx_">popLast()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove and return the largest member in this bag, or return <code>nil</code> if the bag is empty.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">popLast</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L705-L707">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag9removeAllFT_T_"></a>
                    <a name="//apple_ref/swift/Method/removeAll()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag9removeAllFT_T_">removeAll()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove all members from this bag.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">removeAll</span><span class="p">()</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L710-L712">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Sorting"></a>
                <a name="//apple_ref/swift/Section/Sorting" class="dashAnchor"></a>
                <a href="#/Sorting">
                  <h3 class="section-name">Sorting</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag6sortedFT_GSax_"></a>
                    <a name="//apple_ref/swift/Method/sorted()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag6sortedFT_GSax_">sorted()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return an <code>Array</code> containing the members of this bag, in ascending order.</p>

<p><code><a href="../Structs/SortedSet.html">SortedSet</a></code> already keeps its elements sorted, so this is equivalent to <code>Array(self)</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(<code><a href="../Structs/SortedBag.html#/s:vV5BTree9SortedBag5countSi">count</a></code>)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">sorted</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="kt">Element</span><span class="p">]</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L723-L726">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Set%20operations"></a>
                <a name="//apple_ref/swift/Section/Set operations" class="dashAnchor"></a>
                <a href="#/Set%20operations">
                  <h3 class="section-name">Set operations</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag5unionFGS0_x_GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/union(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag5unionFGS0_x_GS0_x_">union(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a bag containing all members from both this bag and <code>other</code>.
The result contains all elements of duplicate members from both bags.</p>

<p>Elements from <code>other</code> follow matching elements from <code>this</code> in the result.</p>

<p>The elements of the two input bags may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input bags will be simply
linked into the result instead of copying, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(<code>self.count</code> + <code>other.count</code>) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">union</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L744-L746">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag9formUnionFGS0_x_T_"></a>
                    <a name="//apple_ref/swift/Method/formUnion(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag9formUnionFGS0_x_T_">formUnion(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Add all members in <code>other</code> to this bag, also keeping all existing instances already in <code>self</code>.</p>

<p>The elements of the two input bags may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input sets will be simply
linked into the result instead of copying, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(<code>self.count</code> + <code>other.count</code>) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">formUnion</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L757-L759">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag12intersectionFGS0_x_GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/intersection(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag12intersectionFGS0_x_GS0_x_">intersection(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a set consisting of all members in <code>other</code> that are also in this bag.
For duplicate members, only as many instances from <code>other</code> are kept in the result that appear in <code>self</code>.  </p>

<p>The elements of the two input sets may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input sets will be simply
linked into the result instead of copying, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">intersection</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L771-L773">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag16formIntersectionFGS0_x_T_"></a>
                    <a name="//apple_ref/swift/Method/formIntersection(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag16formIntersectionFGS0_x_T_">formIntersection(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove all members from this bag that are not also included in <code>other</code>.
For duplicate members, only as many instances from <code>self</code> are kept that appear in <code>other</code>.</p>

<p>The elements of the two input sets may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input sets will be simply
linked into the result instead of copying, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">formIntersection</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L785-L787">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag11subtractingFGS0_x_GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/subtracting(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag11subtractingFGS0_x_GS0_x_">subtracting(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a bag containing those members of this bag that aren&rsquo;t also included in <code>other</code>.
For duplicate members whose multiplicity exceeds that of matching members in <code>other</code>, the extra members are
kept in the result.</p>

<p>The elements of the two input bags may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input bags will be simply
linked into the result instead of copying, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">subtracting</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L800-L802">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag8subtractFGS0_x_T_"></a>
                    <a name="//apple_ref/swift/Method/subtract(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag8subtractFGS0_x_T_">subtract(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove all members from this bag that are also included in <code>other</code>.
For duplicate members whose multiplicity exceeds that of matching members in <code>other</code>, 
the extra members aren&rsquo;t removed.</p>

<p>The elements of the two input bags may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input bags will be simply
linked into the result instead of copying, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">subtract</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L815-L817">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag19symmetricDifferenceFGS0_x_GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/symmetricDifference(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag19symmetricDifferenceFGS0_x_GS0_x_">symmetricDifference(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a bag consisting of members from <code>self</code> and <code>other</code> that aren&rsquo;t in both bags at once.
For members whose multiplicity is different in the two bags, the last <em>d</em> members from the bag with the 
greater multiplicity is kept in the result (where <em>d</em> is the absolute difference of multiplicities).</p>

<p>The elements of the two input bags may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input bags will be simply
linked into the result instead of copying, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">symmetricDifference</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L830-L832">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag23formSymmetricDifferenceFGS0_x_T_"></a>
                    <a name="//apple_ref/swift/Method/formSymmetricDifference(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag23formSymmetricDifferenceFGS0_x_T_">formSymmetricDifference(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Replace <code>self</code> with a set consisting of members from <code>self</code> and <code>other</code> that aren&rsquo;t in both sets at once.</p>

<p>The elements of the two input sets may be freely interleaved.
However, if there are long runs of non-interleaved elements, parts of the input sets will be simply
linked into the result instead of copying, which can drastically improve performance.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">formSymmetricDifference</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L843-L845">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Interactions%20with%20ranges"></a>
                <a name="//apple_ref/swift/Section/Interactions with ranges" class="dashAnchor"></a>
                <a href="#/Interactions%20with%20ranges">
                  <h3 class="section-name">Interactions with ranges</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag5countFT10elementsInGVs5Rangex__Si"></a>
                    <a name="//apple_ref/swift/Method/count(elementsIn:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag5countFT10elementsInGVs5Rangex__Si">count(elementsIn:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return the count of elements in this bag that are in <code>range</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code>self.count</code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">count</span><span class="p">(</span><span class="n">elementsIn</span> <span class="nv">range</span><span class="p">:</span> <span class="kt">Range</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L854-L859">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag5countFT10elementsInGVs11ClosedRangex__Si"></a>
                    <a name="//apple_ref/swift/Method/count(elementsIn:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag5countFT10elementsInGVs11ClosedRangex__Si">count(elementsIn:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return the count of elements in this bag that are in <code>range</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code>self.count</code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">count</span><span class="p">(</span><span class="n">elementsIn</span> <span class="nv">range</span><span class="p">:</span> <span class="kt">ClosedRange</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L864-L869">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag12intersectionFT10elementsInGVs5Rangex__GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/intersection(elementsIn:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag12intersectionFT10elementsInGVs5Rangex__GS0_x_">intersection(elementsIn:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a bag consisting of all members in <code>self</code> that are also in <code>range</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code>self.count</code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">intersection</span><span class="p">(</span><span class="n">elementsIn</span> <span class="nv">range</span><span class="p">:</span> <span class="kt">Range</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L874-L876">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag12intersectionFT10elementsInGVs11ClosedRangex__GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/intersection(elementsIn:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag12intersectionFT10elementsInGVs11ClosedRangex__GS0_x_">intersection(elementsIn:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a bag consisting of all members in <code>self</code> that are also in <code>range</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code>self.count</code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">intersection</span><span class="p">(</span><span class="n">elementsIn</span> <span class="nv">range</span><span class="p">:</span> <span class="kt">ClosedRange</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L881-L883">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag16formIntersectionFT10elementsInGVs5Rangex__T_"></a>
                    <a name="//apple_ref/swift/Method/formIntersection(elementsIn:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag16formIntersectionFT10elementsInGVs5Rangex__T_">formIntersection(elementsIn:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove all members from this bag that are not included in <code>range</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code>self.count</code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">formIntersection</span><span class="p">(</span><span class="n">elementsIn</span> <span class="nv">range</span><span class="p">:</span> <span class="kt">Range</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L888-L890">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag16formIntersectionFT10elementsInGVs11ClosedRangex__T_"></a>
                    <a name="//apple_ref/swift/Method/formIntersection(elementsIn:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag16formIntersectionFT10elementsInGVs11ClosedRangex__T_">formIntersection(elementsIn:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove all members from this bag that are not included in <code>range</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code>self.count</code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">formIntersection</span><span class="p">(</span><span class="n">elementsIn</span> <span class="nv">range</span><span class="p">:</span> <span class="kt">ClosedRange</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L895-L897">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag8subtractFT10elementsInGVs5Rangex__T_"></a>
                    <a name="//apple_ref/swift/Method/subtract(elementsIn:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag8subtractFT10elementsInGVs5Rangex__T_">subtract(elementsIn:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove all elements in <code>range</code> from this bag.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code>self.count</code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">subtract</span><span class="p">(</span><span class="n">elementsIn</span> <span class="nv">range</span><span class="p">:</span> <span class="kt">Range</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L902-L908">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag8subtractFT10elementsInGVs11ClosedRangex__T_"></a>
                    <a name="//apple_ref/swift/Method/subtract(elementsIn:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag8subtractFT10elementsInGVs11ClosedRangex__T_">subtract(elementsIn:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove all elements in <code>range</code> from this bag.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code>self.count</code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">subtract</span><span class="p">(</span><span class="n">elementsIn</span> <span class="nv">range</span><span class="p">:</span> <span class="kt">ClosedRange</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L913-L919">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag11subtractingFT10elementsInGVs5Rangex__GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/subtracting(elementsIn:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag11subtractingFT10elementsInGVs5Rangex__GS0_x_">subtracting(elementsIn:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a bag containing those members of this bag that aren&rsquo;t also included in <code>range</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code>self.count</code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">subtracting</span><span class="p">(</span><span class="n">elementsIn</span> <span class="nv">range</span><span class="p">:</span> <span class="kt">Range</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L924-L928">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree9SortedBag11subtractingFT10elementsInGVs11ClosedRangex__GS0_x_"></a>
                    <a name="//apple_ref/swift/Method/subtracting(elementsIn:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree9SortedBag11subtractingFT10elementsInGVs11ClosedRangex__GS0_x_">subtracting(elementsIn:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a bag containing those members of this bag that aren&rsquo;t also included in <code>range</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code>self.count</code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">subtracting</span><span class="p">(</span><span class="n">elementsIn</span> <span class="nv">range</span><span class="p">:</span> <span class="kt">ClosedRange</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">SortedBag</span><span class="o">&lt;</span><span class="kt">Element</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L933-L937">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Shifting"></a>
                <a name="//apple_ref/swift/Section/Shifting" class="dashAnchor"></a>
                <a href="#/Shifting">
                  <h3 class="section-name">Shifting</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:Fe5BTreeRxs10StrideablerVS_9SortedBag5shiftFT10startingAtx2bywx6Stride_T_"></a>
                    <a name="//apple_ref/swift/Method/shift(startingAt:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:Fe5BTreeRxs10StrideablerVS_9SortedBag5shiftFT10startingAtx2bywx6Stride_T_">shift(startingAt:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Shift the value of all elements starting at <code>start</code> by <code>delta</code>.
For a positive <code>delta</code>, this shifts elements to the right, creating an empty gap in <code>start ..&lt; start + delta</code>.
For a negative <code>delta</code>, this shifts elements to the left, removing any elements in the range <code>start + delta ..&lt; start</code> that were previously in the bag.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(<code>self.count</code>). The elements are modified in place.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">shift</span><span class="p">(</span><span class="n">startingAt</span> <span class="nv">start</span><span class="p">:</span> <span class="kt">Element</span><span class="p">,</span> <span class="n">by</span> <span class="nv">delta</span><span class="p">:</span> <span class="kt">Element</span><span class="o">.</span><span class="kt">Stride</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L948-L961">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:Fe5BTreeRxs10StrideablerVS_9SortedBag5shiftFT10startingAtGVS_10BTreeIndexxT__2bywx6Stride_T_"></a>
                    <a name="//apple_ref/swift/Method/shift(startingAt:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:Fe5BTreeRxs10StrideablerVS_9SortedBag5shiftFT10startingAtGVS_10BTreeIndexxT__2bywx6Stride_T_">shift(startingAt:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Shift the value of all elements starting at index <code>start</code> by <code>delta</code>.</p>

<p>This variant does not ever remove elements from the bag; if <code>delta</code> is negative, its absolute value
must not be greater than the difference between the element at <code>start</code> and the element previous to it (if any).</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    `start == self.startIndex || self[self.index(before: startIndex)] &lt;= self[index] + delta

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(<code>self.count</code>). The elements are modified in place.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">shift</span><span class="p">(</span><span class="n">startingAt</span> <span class="nv">start</span><span class="p">:</span> <span class="kt">Index</span><span class="p">,</span> <span class="n">by</span> <span class="nv">delta</span><span class="p">:</span> <span class="kt">Element</span><span class="o">.</span><span class="kt">Stride</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/SortedBag.swift#L970-L984">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </div>
        </section>

      </article>
    </div>
    <section class="footer">
      <p>&copy; 2016 <a class="link" href="https://twitter.com/lorentey" target="_blank" rel="external">Károly Lőrentey</a>. All rights reserved. (Last updated: 2016-11-08)</p>
      <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
    </section>
  </body>
</div>
</html>
